package com.shengqiang.zhenhuiTransfer.utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * Created by Administrator on 2018/5/24.
 */
public class DateUtils {

    private static final Logger logger= LoggerFactory.getLogger(DateUtils.class);

    public static String getMonthMaxDay(String monthDay){
        try{
            SimpleDateFormat format=new SimpleDateFormat("yyyy-MM");
            Date date=format.parse(monthDay);
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(date);
            int maxDay=calendar.getActualMaximum(calendar.DATE);
            return monthDay+"-"+maxDay;
        }catch (Exception ex){
            logger.error("求当前月的最大日期出现异常:{}",ex.getMessage(),ex);
            return null;
        }
    }
}
